/**
 * Created by Administrator on 2017/3/27 0027.
 */
ControlCenter={
    Create:function(){
        var cc={enalbed:true};
        var page1,page2,page3,page4,pageCircle,page5;
        var pageIndex=1;

        var bl=false;

        var cc_orientRot_beta=0;

        cc.Go=function(){
            page1=Page1.Create();
            page1.start();
            setTimeout(function(){
                bl=true;
            },2000)

            page2=Page2.Create();

            page3=Page3.Create();
            // page3.start();


            page4=Page4.Create();
            // page4.start();

            page5=Page5.Create();
            // page5.start();

            pageCircle=PageCircle.Create();
            // pageCircle.start();
            // goFinal=true;

            // document.addEventListener("FinalPage",function(){
            //
            // });
            document.addEventListener("FinalPage",function(){
                setTimeout(function(){
                    page5.start();
                },2500)

                pageCircle.end();
                renderer.setClearColor(0x000000);
                page2.change();

                setTimeout(function(){
                    goFinal=false;
                },4500)
            })
            window.addEventListener("deviceorientation", function(e){
                // alert('111111');
                pageCircle.gp.position.z=30;
                if(pageCircle.gp)
                {
                    pageCircle.gp.rotation.y=e.beta*0.05;
                }

                // cc_orientRot_beta=e.beta;
            }, false);


            document.addEventListener("mousedown",function(){
                if(bl) {
                    console.log("123");
                    pageIndex++;
                    switch (pageIndex) {
                        case 2:
                            page1.end();
                            setTimeout(function () {
                                page2.start();
                            }, 1400);

                            bl = false;
                            setTimeout(function () {
                                bl = true;
                            }, 2700);
                            break;
                        case 3:
                            page2.end();
                            setTimeout(function () {
                                page3.start();
                                // page2.change();
                            }, 1200)
                            bl = false;
                            setTimeout(function () {
                                bl = true;
                            }, 2700);
                            ;
                            break;
                        case 4:
                            page3.end();
                            setTimeout(function () {
                                page4.start();
                            }, 1400)
                            bl = false;
                            setTimeout(function () {
                                bl = true;
                            }, 2700);
                            ;
                            break;
                        case 5:
                            page4.end();
                            pageCircle.start();
                            page2.Invisible();
                            setTimeout(function(){
                                page2.change();
                            },1000);
                            bl = false;
                            document.dispatchEvent(new CustomEvent("bala"))
                            ;
                            break;
                    }
                }
            })

            document.addEventListener("touchstart",function(){
                if(bl) {
                    console.log("123");
                    pageIndex++;
                    switch (pageIndex) {
                        case 2:
                            page1.end();
                            setTimeout(function () {
                                page2.start();
                            }, 1200);

                            bl = false;
                            setTimeout(function () {
                                bl = true;
                            }, 2500);
                            break;
                        case 3:
                            page2.end();
                            setTimeout(function () {
                                page3.start();
                                // page2.change();
                            }, 1200)
                            bl = false;
                            setTimeout(function () {
                                bl = true;
                            }, 3500);
                            ;
                            break;
                        case 4:
                            page3.end();
                            setTimeout(function () {
                                page4.start();
                            }, 1200)
                            bl = false;
                            setTimeout(function () {
                                bl = true;
                            }, 2500);
                            ;
                            break;
                        case 5:
                            page4.end();
                            pageCircle.start();
                            page2.Invisible();
                            setTimeout(function(){
                                page2.change();
                            },1000);
                            bl = false;
                            // document.dispatchEvent(new CustomEvent("bala"))
                            goFinal=true
                            ;
                            break;
                    }
                }
            })



        }
        cc.DoIt=function(){
            if(pageCircle){
                pageCircle.DoIt();
            }
            if(page2){
                page2.DoIt();
            }
        }
        return cc;
    }
}